<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="statisticServicesPeriod" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="ru/apertum/qsystem/reports/templates/i3-label-rep" uuid="fde42abc-be99-4a19-8a5d-95b68facaecc">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="sd" class="java.util.Date"/>
	<parameter name="ed" class="java.util.Date"/>
	<parameter name="ed1" class="java.util.Date"/>
	<queryString>
		<![CDATA[select rep.name AS responses_name, count(rep.name)  AS responses_count,
(select count(*) from response_event e where  e.resp_date >=$P{sd}  and  e.resp_date <=$P{ed1}) as all_count
from response_event rev
join responses rep  on rev.response_id=rep.id
where  rev.resp_date >=$P{sd}  and  rev.resp_date <=$P{ed1}
group by rep.name
order by  responses_name]]>
	</queryString>
	<field name="responses_name" class="java.lang.String"/>
	<field name="responses_count" class="java.lang.Long"/>
	<field name="all_count" class="java.lang.Long"/>
	<variable name="amount" class="java.lang.Long" calculation="Sum">
		<variableExpression><![CDATA[$F{responses_count}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Long(0)]]></initialValueExpression>
	</variable>
	<title>
		<band height="67">
			<line>
				<reportElement uuid="ccc03e13-f6ec-438d-84b8-f565789b0a41" x="0" y="8" width="555" height="1"/>
			</line>
			<line>
				<reportElement uuid="f67c3194-11cf-4db0-a166-cd1b47304655" positionType="FixRelativeToBottom" x="0" y="61" width="555" height="1"/>
			</line>
			<textField>
				<reportElement uuid="73b5feae-9d59-4bc0-8b70-cda6ea09b6ed" x="1" y="9" width="554" height="26"/>
				<textElement textAlignment="Center" markup="none">
					<font size="18" isBold="true" isStrikeThrough="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{statistic_period_responses}]]></textFieldExpression>
			</textField>
			<textField pattern="">
				<reportElement uuid="cb3c547f-b1f3-4350-bc98-5b5bac6c032d" x="1" y="35" width="554" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" isUnderline="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{from_date} + " " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{sd}) + " "+ $R{to_date} +" " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{ed})]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band/>
	</pageHeader>
	<columnHeader>
		<band height="334">
			<rectangle>
				<reportElement uuid="bba49d32-b936-43a5-b238-04ce57ee0064" x="1" y="314" width="423" height="20" backcolor="#CCCCFF"/>
			</rectangle>
			<rectangle>
				<reportElement uuid="2b75efea-ce36-484b-b6bc-f3ca2e9a5e38" x="424" y="314" width="131" height="20" backcolor="#CCCCFF"/>
			</rectangle>
			<pieChart>
				<chart evaluationTime="Report">
					<reportElement uuid="2417b7cd-fcf6-4de3-9ab3-9115d7c4f282" x="1" y="20" width="554" height="284"/>
					<chartTitle/>
					<chartSubtitle/>
					<chartLegend/>
				</chart>
				<pieDataset>
					<keyExpression><![CDATA[$F{responses_name}+" "+(new java.lang.Double($F{responses_count}.floatValue()/$F{all_count}.floatValue()*100.0)).intValue()+"%"]]></keyExpression>
					<valueExpression><![CDATA[$F{responses_count}]]></valueExpression>
				</pieDataset>
				<piePlot>
					<plot/>
					<itemLabel/>
				</piePlot>
			</pieChart>
			<textField>
				<reportElement uuid="98c42925-a53b-4ad5-8a6e-d049df64237d" x="1" y="0" width="555" height="20"/>
				<textElement textAlignment="Center">
					<font size="14" isBold="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{resp_count} +": "+$F{all_count}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="8979a953-f5ea-4fb8-a24a-cfc963cc6e92" x="1" y="315" width="423" height="19" backcolor="#CCCCFF"/>
				<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
					<font size="12" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{response_type}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="de029536-f511-4d28-8358-7944bb751812" x="424" y="315" width="128" height="19"/>
				<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
					<font size="12" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{amount}]]></textFieldExpression>
			</textField>
		</band>
	</columnHeader>
	<detail>
		<band height="20">
			<rectangle>
				<reportElement uuid="f39ba74d-06f3-4049-8b87-532a6a7ebb35" x="1" y="0" width="423" height="20" backcolor="#CCCCFF"/>
				<graphicElement>
					<pen lineWidth="1.0" lineStyle="Solid"/>
				</graphicElement>
			</rectangle>
			<rectangle>
				<reportElement uuid="788f62df-8c13-4a09-934d-48a952089d22" x="424" y="0" width="131" height="20" backcolor="#CCCCFF"/>
				<graphicElement>
					<pen lineWidth="1.0" lineStyle="Solid"/>
				</graphicElement>
			</rectangle>
			<textField isStretchWithOverflow="true">
				<reportElement uuid="983bec8d-7099-40c7-b1fe-e87e63956a56" stretchType="RelativeToBandHeight" mode="Transparent" x="13" y="1" width="411" height="19" backcolor="#CCCCFF"/>
				<textElement textAlignment="Left" verticalAlignment="Middle">
					<font size="12" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{responses_name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="4ac7da1d-f74e-49a7-9729-bb09724d0ebf" mode="Transparent" x="424" y="1" width="131" height="19" backcolor="#CCCCFF"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="12" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{responses_count}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="50"/>
	</columnFooter>
	<pageFooter>
		<band height="21">
			<textField evaluationTime="Report" pattern="" isBlankWhenNull="false">
				<reportElement uuid="bb5f7b19-a7f4-4667-aec0-21ebcdf646fc" key="textField" x="516" y="2" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="db976364-7481-48c3-9031-6708fa6ddb72" key="textField" x="296" y="2" width="216" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["Страница " + $V{PAGE_NUMBER} + " из "]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="585fcfb8-4d46-41ae-bd79-28bc79a906f1" key="textField" x="1" y="2" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
</jasperReport>
